<template>
  <a-drawer
    :title="title"
    width="50%"
    :visible="visible"
    @close="
      () => {
        this.visible = false
      }
    "
  >
    <a-table :columns="columns" :dataSource="data" bordered :pagination="false">
      <template slot="title" slot-scope="currentPageData">
        <span slot="title" style="color: blue">潜在客户信息</span>
      </template>
    </a-table>
    <div
      :style="{
        position: 'absolute',
        right: 0,
        bottom: 0,
        width: '100%',
        borderTop: '1px solid #e9e9e9',
        padding: '10px 16px',
        background: '#fff',
        textAlign: 'right',
        zIndex: 1
      }"
    >
      <a-button @click="close">关闭</a-button>&nbsp;
      <!-- <a-button type="primary" @click="handleSubmit">保存</a-button> -->
    </div>
  </a-drawer>
</template>

<script>
const columns = [
  // { title: '备注', dataIndex: 'Remark', width: '10%' },
  { title: '客户编码 ', dataIndex: 'cCusCode' },
  { title: '客户名称', dataIndex: 'cCusName' },
  { title: '电话 ', dataIndex: 'cCusPhone' },
  { title: '银行账号', dataIndex: 'cCusAccount' },
  { title: '开户银行', dataIndex: 'cCusBank' },
  { title: '地址', dataIndex: 'cCusAddress' },
  { title: '联系人', dataIndex: 'cCusPerson' },
  { title: '客户来源', dataIndex: 'CustomerOrigin' }
  // { title: '更新时间', dataIndex: 'UpdateTime' },
  // {
  //   title: '创建时间',
  //   dataIndex: 'CreateTime',
  //   align: 'center',
  //   scopedSlots: { customRender: 'CreateTime' }
  // }
]
export default {
  props: {
    parentObj: Object
  },
  data() {
    return {
      data: [],
      columns,
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 18 }
      },
      visible: false,
      loading: false,
      entity: {},
      rules: {},
      title: ''
    }
  },
  methods: {
    init() {
      this.visible = true
      this.entity = {}
    },
    close() {
      this.visible = false
      this.data = []
      this.entity = {}
    },
    openForm(id, title) {
      this.init()
      this.title = title
      if (id) {
        this.loading = true
        this.$http.post('/CustomerManagement/Cust_CustomerInfoPotential/GetTheData', { id: id }).then(resJson => {
          this.loading = false

          this.data = [resJson.Data]
          //console.log(this.data, resJson.Data)
        })
      }
    },
    handleSubmit() {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loading = true
        this.$http.post('/ProductManagement/PDM_Inventory/SaveData', this.entity).then(resJson => {
          this.loading = false

          if (resJson.Success) {
            this.$message.success('操作成功!')
            this.visible = false

            this.parentObj.getDataList()
          } else {
            this.$message.error(resJson.Msg)
          }
        })
      })
    }
  }
}
</script>
